﻿#pragma once
#include "LibXml/JumpXml.h"
#include "Singleton.h"

enum SessionType
{
    SHAANXI = 108,
    SICHUAN = 136,
    GUANGDONG = 136,
};

enum Postion
{
    EAST,
    NORTH,
    WEST,
    SOUTH,
    DEFAULT
};

enum SitPostion
{
    MAIN,
    RIGHT,
    TOP,
    LEFT
};

enum SessionAction
{
    ACTION_DISPATH,
    ACTION_OUTPUT,
    ACTION_CHI,
    ACTION_PENG,
    ACTION_GANG,
    ACTION_ANGANG,
    ACTION_XUGANG,
    ACTION_HU,
    ACTION_ZIMO,
    ACTION_LIUJU
};

enum ChessType
{
    BING = 0,
    WAN = 1,
    TIAO = 2,
    DF = 3,
    XF = 4,
    NF = 5,
    BF = 6,
    Zh = 7,
    Fa = 8,
    Bai = 9,
};

enum ChessStatus
{
    CHI,
    PENG,
    GANG,
    ANGANG,
    XUGANG,
    HU,
    ZI_MO,
    EYE,
    SHUN,
    EEE
};

enum RoleType
{
    HOST,
    CLIENT
};

enum SessionEnum
{
    MAX_PLAYER_SIZE = 4
};

enum OutputPrivillageEnum
{
    P_1 = 2000,
    P_XX = 100,
    P_AB = 110,
    P_AC = 1000,
    P_AE = 1900,
    P_XXX = 50,
    P_AAB_ABB = 60,
    P_ABC = 49,
    P_ABD_ACD = 1700,
    P_ACE = 900,
    P_ACF_ADF = 600,
};

struct UserInfo : public JumpXml
{
    std::string id;
    std::string name;
    std::string ico;
    std::vector<short> histroyScore;

    void xml2Val() override;

    void val2Xml() override;

    ~UserInfo();
};

struct SettingConf : public JumpXml
{
    short SessionType;
    bool CanChi;
    bool CanPeng;
    bool CanGang;
    bool CanHu;

    void xml2Val() override;

    void val2Xml() override;
};

struct Chess
{
    short id;
    ChessType type;
    short count;
    Chess();

    Chess(ChessType tp, short ct);

    Chess(const Chess& rhs);

    const Chess& operator=(const Chess& rhs);

    bool operator==(const Chess& rhs) const;

    bool operator!=(const Chess& rhs) const;

    bool operator<(const Chess& rhs) const;

    short getIdentify() const;

    short getTypeIdentify() const;
};

struct KindChess
{
    ChessStatus type;
    std::vector<Chess> item;
    ~KindChess();
    bool operator==(const KindChess& rhs) const;
};

struct SessionPlayer
{
    std::string id;
    std::string name;
    std::string ico;
    Postion postion;
    RoleType role;
    short score;

    SessionPlayer()
    {
        postion = Postion::DEFAULT;
        role = RoleType::CLIENT;
        score = 0;
    }
};

struct ShowOffsetPair
{
    short tailStartOffset;
    short tailEndOffset;
    short startOffset;
    short endOffset;
    ShowOffsetPair()
    {
        tailStartOffset = 0;
        tailEndOffset = 0;
        startOffset = 0;
        endOffset = 0;
    }
};

struct PrivilageChess
{
    unsigned int privilage;
    Chess outputChess;
    std::vector<Chess> chessVec;
};

struct SessionActionInfo
{
    SessionAction action;
    SitPostion sitPsn;
    Postion activePsn;
    Postion currentPsn;
    std::vector<Chess> handChess;
    std::vector<KindChess> handWeaveChess;
    Chess outputChess;
    std::vector<KindChess> tmpWeaveChess;
    SessionPlayer sessionPlayer;
};

struct OutcutActionInfo
{
    Postion activePsn;
    Postion currentPsn;
    SessionAction action;
    Chess outputChess;
    KindChess tmpWeaveChess;
};